home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / examples / menutree.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1991-10-06  |  8.3 KB  |  183 lines

  1. ; -*-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         menutree.lsp
  5. ; RCS:          $Header: menutree.lsp,v 1.1 91/10/05 21:29:54 mayer Exp $
  6. ; Description:  Simple menu tree program... see below
  7. ; Author:       Niels Mayer, HPLabs
  8. ; Created:      Sat Oct  5 21:24:29 1991
  9. ; Modified:     Sat Oct  5 21:29:04 1991 (Niels Mayer) mayer@hplnpm
  10. ; Language:     Lisp
  11. ; Package:      N/A
  12. ; Status:       X11r5 contrib tape release
  13. ;
  14. ; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. ;
  17. ; Permission to use, copy, modify, distribute, and sell this software and its
  18. ; documentation for any purpose is hereby granted without fee, provided that
  19. ; the above copyright notice appear in all copies and that both that
  20. ; copyright notice and this permission notice appear in supporting
  21. ; documentation, and that the name of Hewlett-Packard and Niels Mayer not be
  22. ; used in advertising or publicity pertaining to distribution of the software
  23. ; without specific, written prior permission.  Hewlett-Packard and Niels Mayer
  24. ; makes no representations about the suitability of this software for any
  25. ; purpose.  It is provided "as is" without express or implied warranty.
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27.  
  28. ; To: davis@hplabs.hpl.hp.com (Jim Davis)
  29. ; Subject: Re: Want Menu-tree program 
  30. ; Newsgroups: comp.windows.x
  31. ; In-reply-to: Your message of 23 Aug 91 00:19:09 +0000
  32. ; Organization: Hewlett-Packard Labs, Software & Systems Lab, Palo Alto, CA.
  33. ; X-Mailer: mh6.7
  34. ; --------
  35. ; WINTERP is quite handy for building menu trees and associated actions
  36. ; without having to mess with C compiles and low-level junk. 
  37. ; I have two possible solutions for you. One is the WINTERP Xmu menu server
  38. ; package that was contributed by Richard Hess of Consilium, Inc. I also
  39. ; quickly cobbled together a Winterp-Lisp file which does the basics of what
  40. ; you want.
  41. ; > Where can I find such a program?  (Additional points are scored if the
  42. ; > program has a concept of string valued 'variables' that can be modified
  43. ; > through text widgets so I needn't keep using my cut buffer for such things.
  44. ; > More additional points for source, and someone to whom I can convey
  45. ; > enhancements.)
  46. ; The winterp-lisp program below has this. I put a Motif text editor
  47. ; widget in there, and you can access the string in the widget by
  48. ; sending it message :GET_STRING. See code below for details.
  49. ;             --------------------
  50. ;
  51. ; Here's the primitive menu tree I cobbled together. It contains a menu-bar
  52. ; with cascade-buttons "hplstl" hplhcid" "hplptd" and each cascase button has
  53. ; a pulldown with entries "xterm" "hpterm" "emacs" "xmh" "edit file in
  54. ; editor". The latter will use the value you type into the text edit widget
  55. ; in order to determine which file to edit.... 
  56. ; The menubar and pulldown entries are all mnemonically driven, which means
  57. ; you don't have to use a mouse if you don't want to.
  58.  
  59. (progn
  60.  
  61. (setq toplevel_w
  62.       (send TOP_LEVEL_SHELL_WIDGET_CLASS :new 
  63.         :XMN_TITLE "MenuTree"
  64.         :XMN_ICON_NAME "MenuTree"
  65.         ))
  66.  
  67. (setq rc_w
  68.       (send XM_ROW_COLUMN_WIDGET_CLASS :new :managed "rc" toplevel_w
  69.         ))
  70.  
  71. (setq menubar_w
  72.     (send XM_ROW_COLUMN_WIDGET_CLASS :new :managed :simple_menu_bar
  73.           "menubar" rc_w
  74.           :XMN_BUTTON_COUNT        3
  75.           :XMN_BUTTONS        #("hplstl" "hplhcid" "hplptd")
  76.           :XMN_BUTTON_MNEMONICS    #(#\s     #\h        #\p     )
  77.           ))
  78.  
  79. (setq edit_w
  80.       (send XM_TEXT_WIDGET_CLASS :new :managed "edit" rc_w
  81.         ))
  82.  
  83. (setq hplstl_pd_w
  84.       (send XM_ROW_COLUMN_WIDGET_CLASS :new :simple_pulldown_menu
  85.         "pulldown" menubar_w
  86.         :XMN_POST_FROM_BUTTON 0    ;post pulldown from menubar's 0th item
  87.         :XMN_BUTTON_COUNT 5        ;create five buttons in this pulldown
  88.         :XMN_BUTTONS           #("xterm" "hpterm" "emacs" "xmh" "edit file in editor")
  89.         :XMN_BUTTON_MNEMONICS       #(#\x     #\h      #\e     #\m    #\e)
  90. ;;;        :XMN_BUTTON_ACCELERATORS       #("Ctrl<Key>C" "Ctrl<Key>F" "Ctrl<Key>O" "Ctrl<Key>S" "Ctrl<Key>W")
  91. ;;;        :XMN_BUTTON_ACCELERATOR_TEXT #("^C" "^F" "^O" "^S" "^W")
  92.         )
  93.       )
  94.  
  95. (send hplstl_pd_w :add_callback :xmn_entry_callback ;use this instead of XmNsimpleCallback
  96.       '(CALLBACK_ENTRY_WIDGET)
  97.       '(
  98.     ;; (send CALLBACK_ENTRY_WIDGET :name) returns "button_<#>"
  99.     ;; where <#> is 0 ... (button-count-1).
  100.     ;; we use 'read' to return the FIXNUM <#> after truncating the
  101.     ;; 7 chars "button_" from the front of the string.
  102.     (case (read (make-string-input-stream (send CALLBACK_ENTRY_WIDGET :name) 7))
  103.           (0 (system "xhost hplstl ; remsh hplstl \"env DISPLAY=hplnpm:0.0 /usr/bin/X11/xterm \" &"))
  104.           (1 (system "xhost hplstl ; remsh hplstl \"env DISPLAY=hplnpm:0.0 /usr/bin/X11/hpterm \" &"))
  105.           (2 (system "xhost hplstl ; remsh hplstl \"env DISPLAY=hplnpm:0.0 /usr/local/bin/x11emacs \" &"))
  106.           (3 (system "xhost hplstl ; remsh hplstl \"env DISPLAY=hplnpm:0.0 /usr/local/bin/X11/xmh \" &"))
  107.           (4 (system (strcat
  108.               "xhost hplstl ; remsh hplstl \"env DISPLAY=hplnpm:0.0 /usr/local/emacs/bin300/gnuclient "
  109.               (send edit_w :get_string)
  110.               " &")))
  111.           (T (system "Error\n")))
  112.     ))
  113.  
  114. (setq hplhcid_pd_w
  115.       (send XM_ROW_COLUMN_WIDGET_CLASS :new :simple_pulldown_menu
  116.         "pulldown" menubar_w
  117.         :XMN_POST_FROM_BUTTON 1    ;post pulldown from menubar's first button.
  118.         :XMN_BUTTON_COUNT 5        ;create five buttons in this pulldown
  119.         :XMN_BUTTONS           #("xterm" "hpterm" "emacs" "xmh" "edit file in editor")
  120.         :XMN_BUTTON_MNEMONICS       #(#\x     #\h      #\e     #\m    #\e)
  121. ;;;        :XMN_BUTTON_ACCELERATORS       #("Ctrl<Key>C" "Ctrl<Key>F" "Ctrl<Key>O" "Ctrl<Key>S" "Ctrl<Key>W")
  122. ;;;        :XMN_BUTTON_ACCELERATOR_TEXT #("^C" "^F" "^O" "^S" "^W")
  123.         ))
  124.  
  125. (send hplhcid_pd_w :add_callback :xmn_entry_callback ;use this instead of XmNsimpleCallback
  126.       '(CALLBACK_ENTRY_WIDGET)
  127.       '(
  128.     ;; (send CALLBACK_ENTRY_WIDGET :name) returns "button_<#>"
  129.     ;; where <#> is 0 ... (button-count-1).
  130.     ;; we use 'read' to return the FIXNUM <#> after truncating the
  131.     ;; 7 chars "button_" from the front of the string.
  132.     (case (read (make-string-input-stream (send CALLBACK_ENTRY_WIDGET :name) 7))
  133.           (0 (system "xhost hplhcid ; remsh hplhcid \"env DISPLAY=hplnpm:0.0 /usr/bin/X11/xterm \" &"))
  134.           (1 (system "xhost hplhcid ; remsh hplhcid \"env DISPLAY=hplnpm:0.0 /usr/bin/X11/hpterm \" &"))
  135.           (2 (system "xhost hplhcid ; remsh hplhcid \"env DISPLAY=hplnpm:0.0 /usr/local/bin/x11emacs \" &"))
  136.           (3 (system "xhost hplhcid ; remsh hplhcid \"env DISPLAY=hplnpm:0.0 /usr/local/bin/X11/xmh \" &"))
  137.           (4 (system (strcat
  138.               "xhost hplhcid ; remsh hplhcid \"env DISPLAY=hplnpm:0.0 /usr/local/emacs/bin300/gnuclient "
  139.               (send edit_w :get_string)
  140.               " &")))
  141.           (T (system "Error\n")))
  142.     ))
  143.  
  144. (setq hplptd_pd_w
  145.       (send XM_ROW_COLUMN_WIDGET_CLASS :new :simple_pulldown_menu
  146.         "pulldown" menubar_w
  147.         :XMN_POST_FROM_BUTTON 2    ;post pulldown from menubar's second button.
  148.         :XMN_BUTTON_COUNT 5        ;create five buttons in this pulldown
  149.         :XMN_BUTTONS           #("xterm" "hpterm" "emacs" "xmh" "edit file in editor")
  150.         :XMN_BUTTON_MNEMONICS       #(#\x     #\h      #\e     #\m    #\e)
  151. ;;;        :XMN_BUTTON_ACCELERATORS       #("Ctrl<Key>C" "Ctrl<Key>F" "Ctrl<Key>O" "Ctrl<Key>S" "Ctrl<Key>W")
  152. ;;;        :XMN_BUTTON_ACCELERATOR_TEXT #("^C" "^F" "^O" "^S" "^W")
  153.         ))
  154. (send hplptd_pd_w
  155.       :add_callback :xmn_entry_callback    ;use this instead of XmNsimpleCallback
  156.       '(CALLBACK_ENTRY_WIDGET)
  157.       '(
  158.     ;; (send CALLBACK_ENTRY_WIDGET :name) returns "button_<#>"
  159.     ;; where <#> is 0 ... (button-count-1).
  160.     ;; we use 'read' to return the FIXNUM <#> after truncating the
  161.     ;; 7 chars "button_" from the front of the string.
  162.     (case (read (make-string-input-stream (send CALLBACK_ENTRY_WIDGET :name) 7))
  163.           (0 (system "xhost hplptd ; remsh hplptd \"env DISPLAY=hplnpm:0.0 /usr/bin/X11/xterm \" &"))
  164.           (1 (system "xhost hplptd ; remsh hplptd \"env DISPLAY=hplnpm:0.0 /usr/bin/X11/hpterm \" &"))
  165.           (2 (system "xhost hplptd ; remsh hplptd \"env DISPLAY=hplnpm:0.0 /usr/local/bin/x11emacs \" &"))
  166.           (3 (system "xhost hplptd ; remsh hplptd \"env DISPLAY=hplnpm:0.0 /usr/local/bin/X11/xmh \" &"))
  167.           (4 (system (strcat
  168.               "xhost hplptd ; remsh hplptd \"env DISPLAY=hplnpm:0.0 /usr/local/emacs/bin300/gnuclient "
  169.               (send edit_w :get_string)
  170.               " &")))
  171.           (T (system "Error\n")))
  172.     ))
  173.  
  174. (send toplevel_w :realize)
  175.  
  176. )
  177.